﻿using Microsoft.AspNetCore.Mvc;
using Zhp.Auth;
using Zhp.IService.Chat;
using Zhp.Model.Chat;
using Zhp.Model.Common;

namespace Zhp.Api.Controllers.Chat
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ChatMessageReadController : ControllerBase
    {
        private readonly IChatMessageReadService chatMessageReadSvc;
        public ChatMessageReadController(IChatMessageReadService chatMessageReadService)
        {
            chatMessageReadSvc = chatMessageReadService;
        }

        /// <summary>
        /// 查询未读消息
        /// </summary>
        /// <returns></returns>
        [AllowOnline]
        [HttpGet()]
        public async Task<ListRet<ChatMessageModel>> GetNoReadMsgList()
        {
            var list = await chatMessageReadSvc.GetChatMessageNoReadList();

            return new ListRet<ChatMessageModel> { DataList = list };
        }

        /// <summary>
        /// 未读消息标记为已读
        /// </summary>
        /// <returns></returns>
        [AllowOnline]
        [HttpPost()]
        public async Task<bool> UpdateMsgReaded(long msgId, long userId)
        {
            return await chatMessageReadSvc.UpdateMsgReaded(msgId, userId);
        }
    }
}
